home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWViews / Include / FWStatic.h < prev    next >
Encoding:
Text File  |  1996-08-16  |  4.1 KB  |  140 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWStatic.h
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10.  
  11. #ifndef FWSTATIC_H
  12. #define FWSTATIC_H
  13.  
  14. //-----------------------------------------------------------------------------
  15. // Imported Classes
  16. //-----------------------------------------------------------------------------
  17.  
  18. #ifndef FWVIEW_H
  19. #include "FWView.h"
  20. #endif
  21.  
  22. #ifndef FWSTRING_H
  23. #include "FWString.h"
  24. #endif
  25.  
  26. #ifndef FWTXTBOX_H
  27. #include "FWTxtBox.h"
  28. #endif
  29.  
  30. //-----------------------------------------------------------------------------
  31. // FW_CStaticText
  32. //-----------------------------------------------------------------------------
  33.  
  34. class FW_CStaticText: public FW_CView
  35. {
  36. public:
  37.     FW_DECLARE_CLASS
  38.     FW_DECLARE_AUTO(FW_CStaticText)
  39.  
  40.     FW_CStaticText(Environment* ev, 
  41.                     FW_CSuperView* container, 
  42.                     const FW_CRect& bounds, 
  43.                     const FW_CString& text,
  44.                     const FW_CFont& font = FW_kNormalFont,  
  45.                     FW_TextBoxOptions options = FW_kTextBoxClipToBox,
  46.                     const FW_CInk& ink = FW_kNormalTextInk);  
  47.     FW_CStaticText(Environment* ev, 
  48.                     FW_CSuperView* container, 
  49.                     const FW_CTextBoxShape& textboxshape);
  50.     FW_CStaticText(Environment* ev);
  51.                 
  52.     ~FW_CStaticText();
  53.     
  54.     // ----- New API ------
  55.     void                GetText(Environment* ev, FW_CString& text) const;
  56.     void                SetText(Environment* ev, const FW_CString& text, FW_Boolean refresh = TRUE);
  57.     FW_CTextBoxShape*    GetTextBoxShape(Environment* ev);
  58.     
  59.     // ----- inherited from FW_CView
  60.     virtual void         Draw (Environment* ev, ODFacet* facet, ODShape* invalidShape);
  61.  
  62.     // ----- Archiving -----
  63.     static void*        Create(FW_CReadableStream& stream, FW_ClassTypeConstant type);
  64.     static void            Destroy(void* object, FW_ClassTypeConstant type);
  65.     virtual void        Flatten(Environment* ev, FW_CWritableStream& stream) const;
  66.     virtual void        InitializeFromStream(Environment* ev, FW_CReadableStream& stream);
  67.     
  68. private:
  69.     void                 Initialize(Environment* ev, 
  70.                                     const FW_CRect& bounds, 
  71.                                     const FW_CString& text,
  72.                                     const FW_CFont& font, 
  73.                                     FW_TextBoxOptions options, 
  74.                                     const FW_CInk& ink);
  75. private:
  76.     FW_CTextBoxShape*    fTextBoxShape;
  77. };
  78.  
  79. //-----------------------------------------------------------------------------
  80. // FW_CStaticText  In-lines
  81. //-----------------------------------------------------------------------------
  82. inline FW_CTextBoxShape*    FW_CStaticText::GetTextBoxShape(Environment*)
  83. {
  84.     return fTextBoxShape;
  85. }
  86.  
  87. inline void    FW_CStaticText::GetText(Environment*, FW_CString& text) const
  88. {
  89.     fTextBoxShape->GetString(text);
  90. }
  91.  
  92. //-----------------------------------------------------------------------------
  93. // FW_CGroupBox
  94. //-----------------------------------------------------------------------------
  95.  
  96. class FW_CGroupBox: public FW_CStaticText
  97. {
  98. public:
  99.     FW_DECLARE_CLASS
  100.     FW_DECLARE_AUTO(FW_CGroupBox)
  101.  
  102.     FW_CGroupBox (Environment* ev, 
  103.                     FW_CSuperView* container, 
  104.                     const FW_CRect& bounds, 
  105.                     const FW_CString& text, 
  106.                     const FW_CFont& font = FW_kNormalFont,  
  107.                     FW_TextBoxOptions options = FW_kTextBoxClipToBox,
  108.                     const FW_CInk& textInk = FW_kNormalTextInk,  
  109.                     const FW_CInk& frameInk = FW_kNormalInk);
  110.     FW_CGroupBox (Environment* ev, 
  111.                     FW_CSuperView* container, 
  112.                     const FW_CTextBoxShape& textbox,
  113.                     const FW_CInk& frameInk = FW_kNormalInk);
  114.     FW_CGroupBox(Environment* ev);
  115.                 
  116.     ~FW_CGroupBox();
  117.     
  118.     // ----- New API ------
  119.     
  120.     // ----- FW_CView ------
  121.     virtual void         Draw (Environment* ev, ODFacet* facet, ODShape* invalidShape);
  122.  
  123.     // ----- Archiving -----
  124.     static void*        Create(FW_CReadableStream& stream, FW_ClassTypeConstant type);
  125.     static void            Destroy(void* object, FW_ClassTypeConstant type);
  126.     virtual void        Flatten(Environment* ev, FW_CWritableStream& stream) const;
  127.     virtual void        InitializeFromStream(Environment* ev, FW_CReadableStream& stream);
  128.     
  129. protected:
  130.     void        SetLabelRect(Environment* ev, FW_CGraphicContext& gc, FW_CRect& rect);
  131.  
  132. private:
  133.     FW_CInk        fFrameInk;
  134. };
  135.  
  136.  
  137. #endif // FWSTATIC_H
  138.  
  139.  
  140.